package com.weayer.controller;


import com.weayer.dto.PriceRule;
import com.weayer.dto.ResponseResult;
import com.weayer.service.PriceRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @description: Service服务 - 计价 - 价格规则Controller
 * @author: Weayer
 **/
@RestController
@RequestMapping("/price-rule")
public class PriceRuleController {
    @Autowired
    PriceRuleService priceRuleService;

    @PostMapping(value = "/add")
    public ResponseResult add(@RequestBody PriceRule priceRule){
        return priceRuleService.add(priceRule);
    }

    @PostMapping(value = "/edit")
    public ResponseResult edit(@RequestBody PriceRule priceRule){
        return priceRuleService.edit(priceRule);
    }

    @GetMapping(value = "/get-newest")
    public ResponseResult<PriceRule> getNewest(@RequestParam String fareType){
        return priceRuleService.getNewest(fareType);
    }

    @GetMapping(value = "/is-newest")
    public ResponseResult<Boolean> isNewest(@RequestParam String fareType, @RequestParam Integer fareVersion){
        return priceRuleService.isNewest(fareType, fareVersion);
    }

    @PostMapping(value = "/if-exists")
    public ResponseResult<Boolean> ifExists(@RequestBody PriceRule priceRule){
        return priceRuleService.ifExists(priceRule);
    }
}
